#include <iostream>
#include <limits>
using std::cin;
using std::cout;
using std::endl;


/* void inputInt(std::istream & is,int & number){ */
/*     cout << "请输入一个整型数据：" << endl; */
/*     is >> number; */
/*     while(!is.eof()){ */
/*         if(is.bad()){ */
/*             cout << "istream has broken!" << endl; */
/*             return; */
/*         }else if(is.fail()){ */
/*             cout << "输入一个整数啊，看清楚点" << endl; */
/*             is.clear(); */
/*             is.ignore( */
/*                 std::numeric_limits<std::streamsize>::max(), */
/*                 '\n'); */
/*             is >> number; */
/*         }else{ */
/*             cout << "输入成功！" << endl; */
/*             break; */
/*         } */
/*     } */
/* } */

void inputInt(std::istream & is,int & number){
    cout << "请输入一个整型数据：" << endl;
    //逗号表达式的返回值只取决于最后一个逗号之后的表达式返回值
    while(is >> number, !is.eof()){
        if(is.bad()){
            cout << "istream has broken!" << endl;
            return;
        }else if(is.fail()){
            cout << "输入一个整数啊，看清楚点" << endl;
            is.clear();
            is.ignore(
                std::numeric_limits<std::streamsize>::max(),
                '\n');
        }else{
            cout << "输入成功！" << endl;
            break;
        }
    }
}

void test0(){
    int num = 0;
    inputInt(cin,num);
    cout << "num:" << num << endl;
}

void test1(){
    int num = 0;
    cin >> num;
    /* if(cin.good()){ */
    //流对象也可以自动转换成bool
    if(cin){
        cout << "goodbit" << endl;
    }else{
        cout << "other" << endl;
    }
}

void test2(){
    int a = 1,b = 2,c = 3;
    a = b = c;

    /* printf("%p\n",&cout); */
    /* printf("%p\n",&(cout << "hello")); */

    //cout << "hello,"这个表达式的返回值就是cout对象
    cout << "hello," << "world" << endl;

    int num = 10, num2 = 10;
    //链式输入
    //(cin >> num) >> num2;
    //输入流运算符默认以空格符、换行符、制表符作为分隔符
    cin >> num >> num2;
    cout << "num:" << num << endl;
    cout << "num2:" << num2 << endl;
}

int main(void){
    test2();
    return 0;
}
